import { Component, OnInit } from '@angular/core';
import { Events } from '../events'
import { NavController } from '@ionic/angular';
@Component({
  selector: 'app-test-events',
  templateUrl: './test-events.page.html',
  styleUrls: ['./test-events.page.scss'],
})
export class TestEventsPage implements OnInit {
  subscription;
  constructor(public events: Events, public nav: NavController) {
    this.subscription = this.events.getMessage().subscribe(value => {
      var key = value.key;
      var data = value.data;

      console.log('receive data1111 --- ' + key + "-----" + data);
    })
  }

  ngOnInit() {


  }
  onClick() {
    this.events.sendMessage({ key: '传参', data: '传值' });
    // this.subscription.dispose();

    this.events.stop();
    // this.events.publish('key', 'value');
    this.nav.back();
  }

}
